package com.fieldchain.ex.fa100.ui.personal.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.fieldchain.ex.fa100.R;
import com.fieldchain.ex.fa100.bean.InviteBean;
import com.fieldchain.ex.fa100.ui.personal.activity.GuizeActivity1;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/9/16
 */
public class InviteListAdapter extends RecyclerView.Adapter<InviteListAdapter.ViewHolder>{
    private Context mContext;
    private int c1,c2;

    public InviteListAdapter(Context mContext) {
        this.mContext = mContext;
        c1= Color.parseColor("#FF00B05F");
        c2= Color.parseColor("#FFDC3950");
    }
    private List<InviteBean> list = new ArrayList<>();

    public void setData(List<InviteBean> list) {
        this.list.clear();
        this.list.addAll(list);
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(mContext).inflate(R.layout.item_invite,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
//        InviteBean bean=list.get(position);
//        if( bean.getIdCardAuth()==1){
//            holder.tvStatus.setText("已实名");
//            holder.tvStatus.setTextColor(c1);
//        }else{
//            holder.tvStatus.setText("未实名");
//            holder.tvStatus.setTextColor(c2);
//        }
//        holder.tvId1.setText(bean.getGainerId());
//        holder.tvId2.setText(bean.getTriggerId());
//        holder.tvGrade.setText((bean.getTree()==1?"一":"二")+"级");


        holder.linInvite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mContext.startActivity(new Intent(mContext, GuizeActivity1.class));
            }
        });
    }


    @Override
    public int getItemCount() {
        return list.size()+2;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private LinearLayout linInvite;
        private TextView tvTime;
        private TextView tvStatus;
        private TextView tvId1;
        private TextView tvId2;
        private TextView tvGrade;

        public ViewHolder(View itemView) {
            super(itemView);
            linInvite = itemView.findViewById(R.id.lin_invite);
            tvTime = itemView.findViewById(R.id.tv_time);
            tvStatus = itemView.findViewById(R.id.tv_status);
            tvId1 = itemView.findViewById(R.id.tv_id1);
            tvId2 = itemView.findViewById(R.id.tv_id2);
            tvGrade = itemView.findViewById(R.id.tv_grade);
        }
    }
}
